@echo off
if "%OS%" == "Windows_NT" setlocal

rem 项目地址
set /p INPUT_DIR=doc-direct:

rem 输出地址
set /p OUT_DIR=out-direct:

set BASE_DIR=%INPUT_DIR%
set DOC_DIR=D:\docbook
set BASE_FOP_DIR=D:\docbook\fop
set CSS_DIR=D:\docbook\docbook-xsl\my\css

set HTML_XSL=d:\docbook\docbook-xsl\my\my.xsl
set OF_XSL=d:\docbook\docbook-xsl\my\myfo.xsl

pushd %BASE_DIR%

rem 生成html文件
xsltproc --xinclude --output book.html %HTML_XSL% book.xml

rem 生成fop文件
xsltproc --xinclude --output book.fo %OF_XSL% book.xml

rem copy 图片资源不然fop生成pdf没有图片
rd %BASE_FOP_DIR%\images\ /s /Q
if not exist "%BASE_FOP_DIR%\images" md %BASE_FOP_DIR%\images
xcopy %BASE_DIR%\images %BASE_FOP_DIR%\images /e 

call D:\docbook\xdoc-fop.bat

rd %BASE_FOP_DIR%\images\ /s /Q

rem 创建输出目录
if not exist "%OUT_DIR%\" md "%OUT_DIR%"

rem 拷贝css
if not exist "%OUT_DIR%\css\" md "%OUT_DIR%\css"
xcopy %CSS_DIR% %OUT_DIR%\css /e /y

rem 拷贝images
if not exist "%OUT_DIR%\images\" md "%OUT_DIR%\images"
xcopy %BASE_DIR%\images %OUT_DIR%\images /e /y

copy /y %BASE_DIR%\book.html %OUT_DIR%\book.html
copy /y %BASE_DIR%\book.pdf %OUT_DIR%\book.pdf

del /a /f /s /q %BASE_DIR%\book.html 
del /a /f /s /q %BASE_DIR%\book.fo 
del /a /f /s /q %BASE_DIR%\book.pdf 

